package com.itheima04;

import java.util.HashMap;
import java.util.Scanner;

public class HomeWork01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String line = sc.nextLine();

        String[] s = line.split(" ");


        HashMap<String, Integer> map = new HashMap<>();


        for (int i = 0; i < s.length; i++) {
            if (map.containsKey(s[i])) {
                Integer count = map.get(s[i]);
                count++;
                map.put(s[i], count);

            } else {
                map.put(s[i], 1);
            }
        }

        map.forEach((key, value) -> System.out.println("单词:" + key + "出现了" + value + "次"));
    }
}
